<?php
require_once BaseUtil::getModulePath("base") . '/models/BaseDao.php';
class RolePermissionsDao extends BaseDao
{
    protected $_name;

    public function  _setup() {
        $this->_name = $this->prefix() . "role_permissions";
        parent::_setup();
    }

    public function getPermissionsByRoleId($roleId){
        $select = $this->db_r->select();
        $select->from($this->_name,"permission_key");
        $select->where('role_id = ?', $roleId);
        $select->where('is_delete = 0');
        $sql = $select->__toString();
        $result = $this->db_r->fetchCol($sql);
        return $result;
    }

    public function deleleByRoleId($roleId){
            $data = array("is_delete" => 1);
            $where = $this->db_w->quoteInto('role_id = ?', $roleId);
            $this->updateData($data,$where);
    }

    public function removeByRoleId($roleId){
        $where = $this->db_w->quoteInto('role_id = ?', $roleId);
        $this->delete($where);
    }
    
}
